package by.epam.trenings.vkphotorest.fragments;

import by.epam.trenings.vkphotorest.R;
import by.epam.trenings.vkphotorest.imageLoader.ImageLoaderCallback;
import by.epam.trenings.vkphotorest.utils.TaskApplication;
import by.epam.trenings.vkphotorest.utils.context.ContextHolder;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class FullScreenFragmentContent extends Fragment {

	public static String EXTRA_PHOTO_SRC = "photo_src";

	public static String EXTRA_PHOTO_DISCRIPTION = "photo_discription";

	private String mSrc;

	private String mDiscription;

	public FullScreenFragmentContent() {

	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle bundle = this.getArguments();
		mDiscription = bundle.getString(EXTRA_PHOTO_DISCRIPTION);
		mSrc = bundle.getString(EXTRA_PHOTO_SRC);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.view_pager_full_screen,
				container, false);

		ImageView imageView = (ImageView) view
				.findViewById(R.id.view_pager_full_screen_image);

		TextView discriotion = (TextView) view
				.findViewById(R.id.view_pager_full_screen_text);

		discriotion.setText(mDiscription);

		TaskApplication.getImageLoader().bind(mSrc, imageView,
				new ImageLoaderCallback() {

					@Override
					public void onSucsess() {
						// TODO Auto-generated method stub

					}

					@Override
					public void onError(Exception e) {

						String warning = ContextHolder
								.getInstance()
								.getContext()
								.getResources()
								.getString(
										R.string.adapter_album_strings_no_internet);

						Toast.makeText(
								ContextHolder.getInstance().getContext(),
								warning + " : " + e.getMessage(),
								Toast.LENGTH_SHORT).show();
					}
				});
		return view;
	}
}
